Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Discord.js | Multiple channel permission - Everyone & created role

I would like to create a channel with specific permissions for @everyone and a created role. So I defined the role as " rolee " and the @everyone at " everyoneRole ", I would like @everyone not to have permission to see the room, and the rolee created before to have permission to see, talk, log in and talk in the room (category type room, but permission is the same).

My code will surely be more concrete: by the way, discord.js is a bit tricky because it only accepts the code if everything is perfectly aligned, which in itself is not a problem, but is when the script doesn't work because of a single misplaced space.

let everyoneRole = message.guild.roles.cache.find(role => role.name === '@everyone');
let rolee = message.guild.roles.cache.find(role => role.name === rolename);

let crole = (
    message.guild.roles.create({
        data: {
            name: rolename,
            color: '3498DB',
        },
    });
);
let cat = (
    message.guild.channels.create(category, {
        type: "category",
        position: 999,
        permissionOverwrites: [
           {
               id: everyoneRole.id,
               deny: [
                   'VIEW_CHANNEL',
                   'SEND_MESSAGES',
               ],
           },
       ]
   });
);

And here is the error message.

My problem is that it refuses to add multiple permission to a single role (allow : ['VIEW_CHANNEL', 'SEND_MESSAGES']).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Note: This answer is for Discord.js v13.3.0


The TypeError is occurring because when you're getting the role from the list of roles, @everyone is technically not a role. While it is a role, you can't get it by requesting it from the role cache.

// When you try to get it from this, Discord.js returns null
let everyoneRole = message.guild.roles.cache.find(role => role.name === '@everyone');

This means that you're handing Discord an empty ID which then causes the issue. The proper way to get the role for everyone, as pointed out by Niet the Dark Absol, is to use <Guild>.roles.cache.everyone (Replace <Guild> with whatever your Guild variable is). Here's what that would look like.

let everyoneRole = message.guild.roles.cache.everyone
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!